﻿
Partial Class MestreCodisDetall
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            Dim codisel As Integer = CInt(Request("codi"))
            Dim mode As String = CStr(Request("mode"))
            If mode = "" Then
                mode = "modificar"
            End If
            ViewState("mode") = mode
            If mode <> "insert" Then
                Dim desc As String = ""
                txtCodi.Text = codisel
                Dim servei As New EsportsLn.MestreCodi
                servei.Obtenir(codisel, desc)
                txtDescripcio.Text = desc
            End If
        End If
    End Sub

    Protected Sub Salvar_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Salvar.Click
        Dim servei As New EsportsLn.MestreCodi
        Dim codisel As Integer = txtCodi.Text
        Dim desc As String = txtDescripcio.Text
        If ViewState("mode") = "insert" Then
            servei.Insertar(codisel, txtDescripcio.Text)
        Else
            servei.Actualitzar(codisel, txtDescripcio.Text)
        End If

        Server.Transfer("MestreCodis.aspx")

    End Sub
End Class
